<%@ page contentType="text/html;charset=UTF-8"%> 
<%@ include file="/framework/purehead.jsp"%>
<%@ page import="java.net.URL"%>
<%@ page import="java.io.DataInputStream"%>
<%
    //获取参数
    String tableName = (String)request.getParameter("tableName");
    if (tableName == null) tableName = "";
    String type = (String)request.getParameter("type");
    if (type == null) type = ""; 
    String warehousecode = (String)request.getParameter("warehousecode");
    if (warehousecode == null) warehousecode = ""; 
    String lastupdatetime = (String)request.getParameter("lastupdatetime");
    if (lastupdatetime == null) lastupdatetime = ""; 
    
    //组合参数
    String strParm = "";
    strParm = "tableName=" + tableName;
    strParm += "&type=" + type;
    strParm += "&warehousecode=" + warehousecode;
    strParm += "&lastupdatetime=" + lastupdatetime;
    
    //通讯DownLoadServlet得到数据文件路径
    URL url = new URL("http" + "://" + "localhost:8080" + "/gw/servlet/GWDownLoadServlet?" + strParm);
    //得到下载文件服务器相对路径
    DataInputStream dis = new DataInputStream(url.openStream());
    String strDownFilePath = dis.readLine();
    dis.close();
    
    String mReturn = "";
    if (strDownFilePath.equalsIgnoreCase(ConstDefine.EXCELFILE_CREATE_ERROR))
    {
        //根据得到的文件路径，下载得到文件
        URL urlfile = new URL("http" + "://" + "localhost:8080" + "/gw" +strDownFilePath);
        DataInputStream disfile = new DataInputStream(urlfile.openStream());
        
        //解析文件并保存到数据库
        try{
            mReturn = GWFileDownProcessor.doExcelSaveToDB(disfile, con, loginInfo,tableName,warehousecode);
        }
        catch(Exception e)
        {
            
        }
        disfile.close();
    }
    else
    {
        mReturn = "0-0-1";
    }        
    
    //记录解吸文件结果信息

    //从返回的值中取得失败和成功的数据
    String tSuccess= mReturn.split("-")[0];
    String tFail= mReturn.split("-")[1];
    String tTotal = mReturn.split("-")[2];  
%>
成功:<%=tSuccess%>笔<br>
失败:<%=tFail%>笔<br>
总计:<%=tTotal%>笔<br>
<%@ include file="/framework/purefoot.jsp"%>